package com.company.action;

import com.company.entity.CompanyInfo;
import com.company.entity.Contacts;
import com.company.entity.Guanjianci;
import com.company.service.CompanyinfoService;
import com.company.service.ContactsService;
import com.company.service.GuanjianciService;
import com.company.service.PageNewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;

public class IndexAction extends BaseAction {

    @Autowired
    CompanyinfoService companyinfoService;
    CompanyInfo companyInfo;
    Contacts contacts;
    ContactsService contactsService;
    PageNewsService pageNewsService;
    Guanjianci guanjianci;
    GuanjianciService guanjianciService;

    public Guanjianci getGuanjianci() {
        return guanjianci;
    }

    public void setGuanjianci(Guanjianci guanjianci) {
        this.guanjianci = guanjianci;
    }

    public GuanjianciService getGuanjianciService() {
        return guanjianciService;
    }

    public void setGuanjianciService(GuanjianciService guanjianciService) {
        this.guanjianciService = guanjianciService;
    }

    public PageNewsService getPageNewsService() {
        return pageNewsService;
    }

    public void setPageNewsService(PageNewsService pageNewsService) {
        this.pageNewsService = pageNewsService;
    }

    public CompanyInfo getCompanyInfo() {
        return companyInfo;
    }

    public void setCompanyInfo(CompanyInfo companyInfo) {
        this.companyInfo = companyInfo;
    }

    public Contacts getContacts() {
        return contacts;
    }

    public void setContacts(Contacts contacts) {
        this.contacts = contacts;
    }

    public CompanyinfoService getCompanyinfoService() {
        return companyinfoService;
    }

    public void setCompanyinfoService(CompanyinfoService companyinfoService) {
        this.companyinfoService = companyinfoService;
    }

    public ContactsService getContactsService() {
        return contactsService;
    }

    public void setContactsService(ContactsService contactsService) {
        this.contactsService = contactsService;
    }

    public String execute(Model model) throws Exception {
        // TODO Auto-generated method stub
        setContacts(contactsService.query());
        model.addAttribute("name", contacts.getName());
        model.addAttribute("phone", contacts.getPhone());
        model.addAttribute("email", contacts.getEmail());
        model.addAttribute("address", contacts.getAddress());
        model.addAttribute("company_info", companyinfoService.query());
        model.addAttribute("Newlist", pageNewsService.querylast());
        model.addAttribute("guanjianci", guanjianciService.query());

        return "ok";
    }
}
